/*******************************************************************************
*  file    : windmainwindow.hpp
*  created : 10.07.2014
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#ifndef WINDMAINWINDOW_HPP
#define WINDMAINWINDOW_HPP

#include <QMainWindow>
#include <QScopedPointer>
#include <QSharedPointer>
#include <QMap>

#include "dataprovider.hpp"
#include "solutions.hpp"

class QTextBrowser;
class QTabWidget;

struct NamedData;
class  SaveFileFormatInterface;
class  TransformNamedData;
class  TransformNamedIntData;
class  ReadFileFormatInterface;
class  SaveLoadObjectInterface;

class WindWidget;
class CalcPlotWidget;
class TransformWindow;
class Solutions;

class windMainWindow final : public QMainWindow
{
    Q_OBJECT
public:
    explicit windMainWindow(QWidget *parent = 0);
private slots:
    void addLogMessage(QString);
    void fillTransformWnd();
    void setFileDataProvider() ;
    void setNetworkDataProvider();
    void findPatterns();
    void findBaseTime();
    void solutuinsTaskDone();
protected:
    void closeEvent(QCloseEvent * event);
    void saveWndState();
    void loadWndState();
protected:
    void changeEvent(QEvent *e);
private:
    void ctrateToolBars();
    void addDock(QString , QWidget *, Qt::DockWidgetArea area = Qt::LeftDockWidgetArea);
    void loadPlugins();
    void populatePlugins(QObject *plugin);

    void resetSolutions();
private:
    QSharedPointer<QMap<QString, TransformNamedData*>>      transformPlugins_     ;
    QSharedPointer<QMap<QString, TransformNamedIntData*>>   transformIntPlugins_  ;
    QSharedPointer<QMap<QString, ReadFileFormatInterface*>> formatPlugins_        ;
    QSharedPointer<QMap<QString, SaveLoadObjectInterface*>> saveLoadObjectPlugins_;
private:
    QTextBrowser   * logBrowser_;
    QTabWidget     * tabWidget_;
    WindWidget     * windWidget_;
    CalcPlotWidget * calcPlotWidget_;
    TransformWindow* transformRespWnd_;
    TransformWindow* transformPulseWnd_;
    QScopedPointer<Solutions,QScopedPointerDeleteLater> solutions_;
    QString          last_opened_dir_;


    QToolBar * mainToolBar_;
    QAction*   calculateAct_;
    QAction*   recalcDirAct_;
    QAction*   setFolderDataAct_;
    QAction*   setNetworkDataAct_;

    QToolBar * windToolBar_;
    QAction*   clearPlotAct_;
    QAction*   findPatternsAct_;
    QAction*   findBaseTimeAct_;

    QAction*   solutionFlushAct_;

    QScopedPointer<DataProvider,QScopedPointerDeleteLater> dataProvider_;
};

#endif // WINDMAINWINDOW_HPP
